const { app, BrowserWindow, BrowserView, webContents, session, ipcMain, } = require('electron');
const path = require('path')

const _browserView = require(path.join(__dirname, '../browserView'))
const _utils = require(path.join(__dirname, '../utils'))



const {logWarn, logError, logSilly, logDebug, logVerbose, logInfo} = require(path.join(__dirname, '../../logger/index.js'))

let _this = null


const getLoginCookie = async (view) => {
  return new Promise(async (resolve, reject) => {
    const _session = view.webContents.session;
    let cookies = await _session.cookies.get({})
    if(cookies){
      let isLogin = false;
      cookies.forEach(item => {
        if(item.name === 'wt2'){
          isLogin = true;
        }
      })
      resolve(isLogin ? cookies : '')
    }else{
      resolve('')
    }
  })
}


let reportUrlMap = {
  'https://z.zhipin.com': 'https://z-zhipin-com.oss-cn-beijing.aliyuncs.com',
  'https://static.zhipin.com': 'https://static-zhipin-com.oss-cn-beijing.aliyuncs.com',
  'https://logapi.zhipin.com': 'https://logapi-zhipin-com.oss-cn-beijing.aliyuncs.com',
  'https://www.zhipin.com': 'https://www-zhipin-com.oss-cn-beijing.aliyuncs.com',
}
const checkJsUrlReport = (url) => {
  if(url.includes('.js') && (url.includes('https://z.zhipin.com') || url.includes('https://static.zhipin.com') || url.includes('https://logapi.zhipin.com') || url.includes('https://www.zhipin.com'))){
    
    if(url.includes('https://apm-fe.zhipin.com/wapi/zpApm/actionLog/fe/ie/common.json') || url.includes('https://www.zhipin.com/wapi/zpCommon/actionLog/common.json')){
      return false
    }

    
    if(url.indexOf('.js') === url.length-3){
      let reportUrl = '';
      for (let key in reportUrlMap) {
        if (url.startsWith(key)) {
          reportUrl = url.replace(key, reportUrlMap[key]);
        }
      }
      return reportUrl
    }
  }
  return false
}


const checkReportRequestUrl = (details) => {
  let isReport = false
  
  try {
    isReport = details.url.includes('fe/common.json') || details.url.includes('https://shink.zhipin.com/') || details.url.includes('https://logapi.zhipin.com/dap/api/json') || details.url.includes('/fe/ie/common.json')
  } catch (error) {
    console.error('checkReportRequestUrl error=>', error)
  }

  
  if(!isReport){
    try {
      if(details.url.includes('https://t.zhipin.com/e.gif') || details.url.includes('https://t.kanzhun.com/z.gif') || details.url.includes('https://t.zhipin.com/_.gif')){
        let formatUrl = details.url
        try {
          formatUrl = decodeURIComponent(details.url)
        } catch (error) {
          console.error('图片请求decodeURIComponent error=>', error)
        }
        if(formatUrl.includes('boss_risk_report') || formatUrl.includes('action_js_risk_monitor') || formatUrl.includes('device-action-report')){
          isReport = true
        }
      }
    } catch (error) {
      console.error('checkReportRequestUrl error=>', error)
    }
  }
  return isReport
}

const reportRequestEvent = (details) => {
  let reportRequestEvent = null
  try {
    if(details.uploadData){
      let dataItem = details.uploadData[0]
      reportRequestEvent = {
        url: details.url,
        method: details.method,
        type: dataItem.type
      }
    }
  } catch (error) {
    console.error('检测类型 error=>>', error)
  }
  return reportRequestEvent
}

const formatReportBlobRequest = (details) => {
  let uploadData = ''
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

  
  return null
}


const formatReportRequest = (options) => {
  let { details, isFormatData, formatImgUrl } = options
  let reportData = null
  try {
    
    
    
    
    
    let uploadData = ''
    if(details.uploadData){
      let dataItem = details.uploadData[0]
      if (dataItem.type == 'rawData') {
        
        uploadData = dataItem.bytes.toString('utf8'); 
        
      }else{
        uploadData = details.uploadData ? dataItem.bytes.toString() : ''
      }
    }
    
    try {
      uploadData = typeof uploadData == 'object' ? Object.stringify(uploadData) : decodeURIComponent(uploadData)
    } catch (error) {
      
    }
    
    
    

    
    if(details.url.includes('/fe/ie/common.json') && !isFormatData && !formatImgUrl){
      return null
    }

    
    try {
      uploadData = JSON.parse(uploadData);
      reportData = uploadData || null
    } catch (error) {
      if(uploadData){
        reportData = {
          uploadData: uploadData
        }
      }
      if(details.method != 'OPTIONS'){
        
      }
    }
    
    
    
    
    
  } catch (error) {
    console.error('拦截common.json error=>>', error)
  }
  return reportData
}


class BossIpc {
  constructor (props) {
    let { mainWindow, local, nowDirname, store, tabStore, mainWindowOptions, formatUserAgent } = props
    _this = this; 
    this.mainWindow = mainWindow;
    this.local = local;
    this.nowDirname = nowDirname;
    this.store = store; 
    this.tabStore = tabStore;
    this.mainWindowOptions = mainWindowOptions;
    this.formatUserAgent = formatUserAgent;
  }
  
  updatemainWindow = (mainWindow) => {
    this.mainWindow = mainWindow
  }

  
  sendToWebFrontend = (data) => {
    let frontendView = this.tabStore.getBrowserView({frontend: true});
    
    let fromViewItem = data.message.viewId ? this.tabStore.getBrowserView({viewId: data.message.viewId}) : null;
    
    if(!!(frontendView && frontendView.viewEvent)){
      if(!!fromViewItem){
        
        data.message.bossUserId = fromViewItem.bossUserId;
        data.message.bossToken = fromViewItem.bossToken;
      }
      frontendView.viewEvent.reply(data.messageType, data.message)
    }
  }
  
  sendToBossTab = (viewId, data) => {
    let frontendView = this.tabStore.getBrowserView({viewId});
    
    if(!!(frontendView && frontendView.viewEvent)){
      frontendView.viewEvent.reply(data.messageType, data.data)
    }
  }
  
  
  initBossIpc = async () => {
    

    
    ipcMain.on('on-render-boss-check-login', this.onCheckBossLogin)

    
    ipcMain.on('on-channel-message-boss-to-webfrontend', this.onBossToWebfrontend)

    
    ipcMain.handle('on-boss-page-forwarding-requests', async (event, message) => {
      let res = {}
      try {
        res = await _utils.forwardingRequests(message)
      } catch (error) {
        console.error('on-boss-page-forwarding-requests error=>', error)
      }
      
      if(message.logOptions && !message.url.includes('/electron-track')){
        
        _utils.reportRequestEvent({
          ...message,
          res
        })
      }
      
      return res
    });

    
    ipcMain.handle('on-boss-page-forwarding-file-requests', async (event, message) => {
      
      let { fileType } = message
      let res = ''
      
      if(fileType === 'getBase64'){
        try {
          res = await _utils.forwardingGetBase64FileRequests(message)
        } catch (error) {
          console.error('on-boss-page-forwarding-requests getBase64 error=>', error)
        }
      }
      
      else if(fileType === 'uploadPdf'){
        try {
          res = await _utils.forwardingUploadAliOssFileRequests(message)
        } catch (error) {
          console.error('on-boss-page-forwarding-requests uploadPdf error=>', error)
        }
      }
      
      return res
    });
    

  }
  
  async onCheckBossLogin (event, data) {
    
    let bossUserCookies = null;
    let bossLoginEvent = null 
    let needAppendCookie = true; 
    let isIniBossListenerMsg = false; 

    
    if(data.type === 'open'){
      try {
        let cookieRes = await _this.store.getDBDate({name: `bossUserCookie.${data.userId}`})
        if(cookieRes.code === 1000 && !!cookieRes.data){
          bossUserCookies = JSON.parse(cookieRes.data)
        }
      } catch (error) {
        
      }
    }

    
    let windowRes = await _browserView.createBossBrowserWindow({
      mainWindow: _this.mainWindow, 
      local: _this.local,
      bossUserCookies,
      nowDirname: _this.nowDirname,
      formatUserAgent: global.formatUserAgent,
      data,
    })
    let window = windowRes.window;

    
    
    
    
    
    
    
    
    

    
    ipcMain.on('on-preload-boss-login-ping', async (event, message) => {
      
      bossLoginEvent = event;
      
      if(needAppendCookie){
        needAppendCookie = false;
        if(!!bossUserCookies){
          event.reply('on-preload-boss-login-append-cookie', {
            type: 'on-preload-boss-login-append-cookie',
            data: bossUserCookies
          })
        }
      }
    })

    
    window.webContents.on('dom-ready', async (e) => {
      let url = window.webContents.getURL()
      
      
      if(url === 'https://www.zhipin.com/web/boss/index' || url === 'https://www.zhipin.com/web/chat/index'){
        
        if(!isIniBossListenerMsg){
          isIniBossListenerMsg = true;
          iniBossListenerMsg()
        }
        
        if(!!bossLoginEvent){
          bossLoginEvent.reply('on-browser-boss-login-check-login', {
            type: 'on-browser-boss-login-check-login',
          })
        }
      }


    })

    const bossCheckLoginListener = async (event, message) => {
      let { res, urlBossUserId } = message
      
      
      if(res && res.code === 0){
        
        
        let userId = res.zpData.userId

        
        
        if(!!urlBossUserId && urlBossUserId>=0 && urlBossUserId != userId){
          
          _this.sendToWebFrontend({
            messageType: 'to-webfrontend-login-account',
            message: {
              data: {
                errorMessage: '账户不一致，请使用同一账号扫码',
              },
              viewId: ''
            }
          });
          
          ipcMain.removeListener('on-preload-boss-login-check-login', bossCheckLoginListener)
          window.close();
          return
        }

        
        let cookies = await getLoginCookie(window)
        
        let storeRes = await _this.store.setDBDate({
          name: `bossUserCookie.${userId}`,
          value: JSON.stringify(cookies)
        })

        
        _this.sendToWebFrontend({
          messageType: 'to-webfrontend-login-account',
          message: {
            data: res.zpData,
            viewId: ''
          }
        });

        
        if(storeRes.code === 1000){
          
          ipcMain.removeListener('on-preload-boss-login-check-login', bossCheckLoginListener)

          window.close();
          
          
          setTimeout(() => {
            _this.openBossPage({
              cookies,
              bossUserId: res.zpData.userId,
              bossToken: res.zpData.token
            });
          }, 1000);
        }
        
      }
    }

    
    const iniBossListenerMsg = () => {
      
      ipcMain.on('on-preload-boss-login-check-login', bossCheckLoginListener)
    }
  }

  
  async openBossPage (options) {
    let { cookies, bossUserId, bossToken } = options
    let partition = bossUserId + ''
    let bossPageEvent = null 
    let needAppendCookie = true; 
    let onUpdateTimer = null 
    
    
    
    let _view = null
    let currentViewId = '';
    let createRes = await _browserView.createBrowserView({
      mainWindow: this.mainWindow, 
      local: this.local,
      formatUserAgent: global.formatUserAgent,
      isBoss: true, 
      data:{
        
        url: 'https://www.zhipin.com/web/chat/index', 
        
        
        width: this.mainWindowOptions.screen.width,
        
        
        height: this.mainWindowOptions.screen.height - 35,
        top: 35+1,
        webPreferences: {
          contextIsolation: false, 
          partition: partition, 
          preload: this.nowDirname + '/src/preload/boss/index.js', 
          
          
          enableRemoteModule: true, 
        },
      },
      onUpdateInfo: (view, data)=> {
        let viewId = view.webContents.id 
        currentViewId = viewId;
        
        
        view.webContents.userAgent = global.formatUserAgent
        view.webContents.setUserAgent(global.formatUserAgent);
        const ses = view.webContents.session
        ses.setUserAgent(global.formatUserAgent)

        clearTimeout(onUpdateTimer)
        if(!!view){
          onUpdateTimer = setTimeout(() => {
            try {
              
              this.tabStore.updateViewTabInfo(view, data)
            } catch (error) {
              
            }
          }, 300);
        }
      },
      
      onReady: (view, event)=> {
        let viewId = view.webContents.id 
        currentViewId = viewId;
        let url = view.webContents.getURL()
        
      },
      
      onFinished: async (view, event)=> {
        let viewId = view.webContents.id 
        currentViewId = viewId;

        
        let availableTime = 0;
        try {
          let storeRes = await _this.store.getDBDate({name: `bossUseRavailableTime.${bossUserId}`})
          
          if(storeRes.code === 1000 && !!storeRes.data){
            availableTime = storeRes.data
          }
        } catch (error) {
          
        }
        if(!availableTime){
          availableTime = new Date(new Date().toLocaleDateString()).getTime() + 1 * 24 * 60 * 60 * 1000
          try {
            
            _this.store.setDBDate({name: `bossUseRavailableTime.${bossUserId}`, value: availableTime})
          } catch (error) {
            
          }
        }

        

        
        _this.sendToBossTab(viewId, {
          messageType: 'on-main-boss-first-login',
          data: {
            bossUserId,
            bossToken,
            availableTime
          }
        });
      },
      
    })
    let customHeaders = {
      apmFeActionLog: [],
      actionLog:{},
    }

    let { view } = createRes
    _view = view

    
    this.tabStore.addViewTab({
      view,
      bossUserId,
      bossToken
    })

    
    
    ipcMain.on('on-preload-boss-page-ping', async (event, message) => {
      let nowViewId = view?.webContents?.id 
      let messageViewId = event.sender.id; 
      
      if(messageViewId === nowViewId){
        
        bossPageEvent = event;
        
        if(needAppendCookie){
          needAppendCookie = false;
          if(!!cookies){
            event.reply('on-preload-boss-page-append-cookie', {
              type: 'on-preload-boss-page-append-cookie',
              data: cookies,
              bossUserId,
              bossToken
            })
          }
        }
      }
    })

    
    ipcMain.on('on-preload-boss-page-customHeaders', async (event, message) => {
      let nowViewId = view?.webContents?.id 
      let messageViewId = event.sender.id; 
      
      if(messageViewId === nowViewId){
        let { type, traceid, headers} = message
        if(type === 'actionLog'){
          customHeaders.actionLog[traceid] = headers
        }else if(type === 'apmFeActionLog'){
          customHeaders.apmFeActionLog.push(headers)
        }
        
        
      }
    })
    

    
    

    
    

    
    

    
    view.webContents.setUserAgent(global.formatUserAgent);
    view.webContents.userAgent = global.formatUserAgent
    let urls1 = '*://';
    let urls2 = '*';
    let urls3 = '/';
    let urls4 = '*';
    let allApiFilter = {
      urls: [`${urls1}${urls2}${urls3}${urls4}`]
    }
    let updateGeekHeadersUrl = ['/zpjob/rec/geek/list', '/zprelation/interaction/bossGetGeek', '/zpjob/chat/start'];
    
    view.webContents.session.webRequest.onBeforeSendHeaders(allApiFilter, (details, callback) => {
      details.requestHeaders['User-Agent'] = global.formatUserAgent;
      details.requestHeaders['user-agent'] = global.formatUserAgent;

      let { geekcustomreferer, geekCustomReferer, geekcustomrefererstatus, Cookie, cookie, traceid} = details.requestHeaders
      
      
      let apmFeLogUrl = 'https://apm-fe.zhipin.com/wapi/zpApm/actionLog/fe/ie/common.json'
      let actionLogUrl = 'https://www.zhipin.com/wapi/zpCommon/actionLog/common.json'

      let geekUrlIndex = updateGeekHeadersUrl.findIndex(itemUrl => {
        return details.url.includes(itemUrl)
      })
      if(geekUrlIndex >= 0 && (geekcustomreferer || geekCustomReferer)){
        
        details.requestHeaders['Referer'] = `https://www.zhipin.com/web/frame/recommend/?filterParams=&t=&inspectFilterGuide=&status=${geekcustomrefererstatus}&jobid=${geekcustomreferer || geekCustomReferer}&source=0`
        delete details.requestHeaders.geekCustomReferer
        delete details.requestHeaders.geekcustomreferer
        delete details.requestHeaders.geekcustomrefererstatus
      }

      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

      
      try {
        if(details.url.includes(apmFeLogUrl) && !(cookie || Cookie)){
          
          let headerObj = customHeaders.apmFeActionLog[0] || {}
          Object.keys(headerObj).forEach(type => {
            details.requestHeaders[type] = headerObj[type]
          })
          
          
          customHeaders.apmFeActionLog.shift()
        }
      } catch (error) {
        console.error('apmFeLogUrl customHeaders error=>', error)
      }

      
      try {
        
        if(details.url.includes(actionLogUrl) && customHeaders.actionLog[traceid] ){
          let headerObj = customHeaders.actionLog[traceid]
          Object.keys(headerObj).forEach(type => {
            details.requestHeaders[type] = headerObj[type]
          })
          
          
          delete customHeaders.actionLog[traceid]
          
        }
      } catch (error) {
        console.error('actionLogUrl customHeaders error=>', error)
      }

      let callbackJson = {
        requestHeaders: details.requestHeaders
      }
      callback(callbackJson);
    })


    
    let bossApiUrlFilter = {
      
      urls: ['*://*/*']
    }
    
    view.webContents.session.webRequest.onBeforeRequest(bossApiUrlFilter, (details, callback) => {
      
      let isFormatData = false; 
      let redirectURL = '';
      let formatImgUrl = '' 

      
      try {
        if(details.url.includes('https://apm-fe.zhipin.com/wapi/zpApm/actionLog/fe/ie/common.json') && details.uploadData){
          let uploadData = details.uploadData[0].bytes.toString()
          
          try {
            uploadData = typeof uploadData == 'object' ? Object.stringify(uploadData) : decodeURIComponent(uploadData)
          } catch (error) {
            
          }
          
          let filterValue = ['_electron', 'ipcRenderer', 'yingReportApiLogs', 'reportRecordInfo', 'testCode', 'yingReportRecordHttpLog', 'stopCrawlingTime', 'stopCrawlingStartTime','IpcMessage','_this','xyChatProtocol', 'XiaoYing', 'XYing']
          filterValue.forEach(item => {
            if(uploadData.includes(item)){
              isFormatData = true
            }
          })
          
          if(!isFormatData){
            if(uploadData.includes('.menu-recommend') && !uploadData.includes('web-event-click')){
              isFormatData = true
            }
          }
        }
      } catch (error) {
        console.error('拦截 apm-fe common.json error=>>', error)
      }

      
      try {
        if(details.url.includes('https://www.zhipin.com/wapi/zpCommon/actionLog/common.json') && details.uploadData){
          let uploadData = details.uploadData[0].bytes.toString()
          
          try {
            uploadData = typeof uploadData == 'object' ? Object.stringify(uploadData) : decodeURIComponent(uploadData)
          } catch (error) {
            
          }
          
          let filterValue = ['_electron', 'ipcRenderer', 'yingReportApiLogs', 'reportRecordInfo', 'testCode', 'yingReportRecordHttpLog', 'stopCrawlingTime', 'stopCrawlingStartTime','IpcMessage','_this','xyChatProtocol', 'XiaoYing', 'XYing']
          filterValue.forEach(item => {
            if(uploadData.toLowerCase().includes(item.toLowerCase())){
              isFormatData = true
            }
          })
          
          
          
        }
      } catch (error) {
        console.error('拦截zhipin common.json error=>>', error)
      }

      
      try {
        if(!isFormatData && details.url.includes('/common.json') && details.uploadData){
          let uploadData = details.uploadData[0].bytes.toString()
          try {
            uploadData = typeof uploadData == 'object' ? Object.stringify(uploadData) : decodeURIComponent(uploadData)
          } catch (error) {
            
          }
          
          let filterValue = ['_electron', 'ipcRenderer', 'yingReportApiLogs', 'reportRecordInfo', 'testCode', 'yingReportRecordHttpLog', 'stopCrawlingTime', 'stopCrawlingStartTime','IpcMessage','_this','xyChatProtocol', 'XiaoYing', 'XYing', 'action_js_risk_monitor', 'device-action-report']
          filterValue.forEach(item => {
            if(uploadData.toLowerCase().includes(item.toLowerCase())){
              isFormatData = true
            }
          })
          
          
          
        }
      } catch (error) {
        
        console.error('拦截zhipin common.json error=>>', error)
      }
   
      
      try {
        if(details.url.includes('https://logapi.zhipin.com/dap/api/json') && details.uploadData){
          let uploadData = details.uploadData[0].bytes.toString()
          
          try {
            uploadData = typeof uploadData == 'object' ? Object.stringify(uploadData) : decodeURIComponent(uploadData)
          } catch (error) {
            
          }
          
          let filterValue = ['electron', 'xiaoying', 'xying'];
          filterValue.forEach(item => {
            if(uploadData.toLowerCase().includes(item.toLowerCase())){
              isFormatData = true
            }
          })
          
          if(isFormatData){
            try {
              uploadData = JSON.parse(uploadData);
              uploadData.events.forEach(item => {
                item.user_agent = global.formatUserAgent;
              })
              

              
              _this.sendToBossTab(currentViewId, {
                messageType: 'on-main-to-boss-retrySendLog',
                data: {
                  url: details.url,
                  method: details.method,
                  uploadData
                }
              });

            } catch (error) {
              console.error('error=>', error)
            }
          }
        }
      } catch (error) {
        console.error('拦截common.json error=>>', error)
      }

      
      try {
        if(details.url.includes('https://t.kanzhun.com')){
          let filterValue = ['XiaoYing', 'XYing', 'Electron']
          if(filterValue.some(item => details.url.toLocaleLowerCase().includes(item.toLocaleLowerCase()))){
            isFormatData = true
          }
        }
      } catch (error) {
        console.error('拦截common.json error=>>', error)
      }

      
      if(details.url.includes('https://t.zhipin.com/e.gif') || details.url.includes('https://t.kanzhun.com/z.gif') || details.url.includes('https://t.zhipin.com/_.gif')){
        let formatUrl = details.url
        try {
          formatUrl = decodeURIComponent(details.url)
        } catch (error) {
          console.error('图片请求decodeURIComponent error=>', error)
        }
        
        if(formatUrl.includes('boss_risk_report') || formatUrl.includes('action_js_risk_monitor') || formatUrl.includes('device-action-report')){
          formatImgUrl = formatUrl
          isFormatData = true
        }
      }

      
      let isLocalBlock = details.url.includes('https://t.zhipin.com/e.gif') || details.url.includes('/common.json') || details.url.includes('https://shink.zhipin.com/wapi/dapCommon/json') || details.url.includes('https://t.kanzhun.com/z.gif') || details.url.includes('https://t.zhipin.com/_.gif');
      if(isLocalBlock && _this.local ){
        isFormatData = true
      }

      
      
      
      

      
      try {
        let jsUrlReportUrl = checkJsUrlReport(details.url)
        if(jsUrlReportUrl){
          _utils.fetchBossJsFile(jsUrlReportUrl)
        }
      } catch (error) {
        console.error('转发js文件 error=>>', error)
      }

      
      if(checkReportRequestUrl(details)){
        
        
        let _reportRequestEvent = reportRequestEvent(details) || {}
        if(_reportRequestEvent.type === 'blob'){
          
          try {
            let reportRequestData = formatReportBlobRequest(details)
            if(reportRequestData){
              
              _this.sendToBossTab(currentViewId, {
                messageType: 'on-main-to-boss-reportBossLogs',
                data: {
                  url: formatImgUrl || details.url,
                  method: details.method,
                  uploadData: reportRequestData,
                  isFormatData: isFormatData
                }
              });
            }
          } catch (error) {
            console.error('判断是否上报这些接口 error=>>', error)
          }
        }else{
          
          try {
            let reportRequestData = formatReportRequest({
              details,
              isFormatData,
              formatImgUrl
            })
            
            
            
            if(reportRequestData || formatImgUrl){
              
              _this.sendToBossTab(currentViewId, {
                messageType: 'on-main-to-boss-reportBossLogs',
                data: {
                  url: formatImgUrl || details.url,
                  method: details.method,
                  uploadData: reportRequestData || {
                    uploadData: formatImgUrl || details.url,
                  },
                  isFormatData: isFormatData
                }
              });
            }
          } catch (error) {
            console.error('判断是否上报这些接口 error=>>', error)
          }
        }
      }

      let callbackJson = {}
      
      if(redirectURL){
        callbackJson.redirectURL = redirectURL
      }

      if(isFormatData){
        callback({
          ...callbackJson,
          cancel: true,
        });
      }else{
        callback({
          ...callbackJson,
          cancel: false
        });
      }
    })


    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  }

  
  async onBossToWebfrontend (event, message){
    let viewId = event.sender.id 
    _this.sendToWebFrontend({
      messageType: 'to-webfrontend-from-boss',
      message: {
        data: message,
        viewId
      }
    });

    try {
      
      let jumpMessage = {
        'updateFriendHistoryMsg': '更新聊天历史',
        'friendList': '同步候选人',
        
      }
      if(!jumpMessage[message.type]){
        logInfo(`to-webfrontend-from-boss=>>> ${JSON.stringify(message)}`)
      }
    } catch (error) {}
  }

}

exports.BossIpc = BossIpc 
